package com.ql.dao;

import com.ql.domain.Project;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ProjectDao {
    /**
     * 根据id查询项目列表
     *
     * @param id
     * @return
     */
    @Select("select * from project where id=#{id}")
    Project findById(String id);

    /**
     * 查询全部及关联的标段
     *
     * @return
     */
/*    @Select("select * from project")
    @Results({
            @Result(id = true, property = "id", column = "id"),
            @Result(property = "projectName", column = "projectName"),
            @Result(property = "projectAbbr", column = "projectAbbr"),
            @Result(property = "create_time", column = "create_time"),
            @Result(property = "orderBy", column = "orderBy"),
            @Result(property = "state", column = "state"),
            @Result(column = "id", property = "sectionList",
                    javaType = List.class,
                    many = @Many(select = "com.ql.dao.SectionDao.findByProjectId"))
    })*/
    List<Project> selectAll();

    /**
     * 查询全部项目包含条件查询
     *
     * @return
     */
    List<Project> findAll(String projectName);


    /**
     * 保存项目
     *
     * @param project
     * @return
     */
    void save(Project project);

    /**
     * 更新项目
     *
     * @param project
     * @return
     */
    void update(Project project);

    /**
     * 删除项目
     *
     * @param id
     */
    @Delete("delete from project where id = #{id}")
    void delProjectById(String id);

    /**
     * 获取账户关联的所有开启的项目集合
     *
     * @return
     */
//    @Select("SELECT * FROM project WHERE id in projectIds state =0 order by orderBy ASC")
    List<Project> projectGroupName(@Param("projectIds") String[] projectIds);

    /**
     * 获取所有的开启的项目
     *
     * @return
     */
    @Select("SELECT * FROM project WHERE state =0 order by orderBy ASC")
    List<Project> allProjectGroupName();

}
